package com.zjcloud.motr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.motr.domain.ZjyTrainingPrograms;
import com.zjcloud.motr.service.IZjyTrainingProgramsService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 培养方案Controller
 * 
 * @author ruoyi
 * @date 2024-08-30
 */
@RestController
@RequestMapping("/motr/programs")
public class ZjyTrainingProgramsController extends BaseController
{
    @Autowired
    private IZjyTrainingProgramsService zjyTrainingProgramsService;

    /**
     * 查询培养方案列表
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZjyTrainingPrograms zjyTrainingPrograms)
    {
        startPage();
        List<ZjyTrainingPrograms> list = zjyTrainingProgramsService.selectZjyTrainingProgramsList(zjyTrainingPrograms);
        return getDataTable(list);
    }

    /**
     * 导出培养方案列表
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:export')")
    @Log(title = "培养方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjyTrainingPrograms zjyTrainingPrograms)
    {
        List<ZjyTrainingPrograms> list = zjyTrainingProgramsService.selectZjyTrainingProgramsList(zjyTrainingPrograms);
        ExcelUtil<ZjyTrainingPrograms> util = new ExcelUtil<ZjyTrainingPrograms>(ZjyTrainingPrograms.class);
        util.exportExcel(response, list, "培养方案数据");
    }

    /**
     * 获取培养方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zjyTrainingProgramsService.selectZjyTrainingProgramsById(id));
    }

    /**
     * 新增培养方案
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:add')")
    @Log(title = "培养方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjyTrainingPrograms zjyTrainingPrograms)
    {
        return toAjax(zjyTrainingProgramsService.insertZjyTrainingPrograms(zjyTrainingPrograms));
    }

    /**
     * 修改培养方案
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:edit')")
    @Log(title = "培养方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjyTrainingPrograms zjyTrainingPrograms)
    {
        return toAjax(zjyTrainingProgramsService.updateZjyTrainingPrograms(zjyTrainingPrograms));
    }

    /**
     * 删除培养方案
     */
    @PreAuthorize("@ss.hasPermi('motr:programs:remove')")
    @Log(title = "培养方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zjyTrainingProgramsService.deleteZjyTrainingProgramsByIds(ids));
    }
}
